// 导入工具utils下二次封装的axios
import request from '@utils/request'
// 请求所有分类接口params传参,定义常量赋值
// const fetchCates = (params = {}) => request.get('/shop/goods/category/all', { params })
export function fetchCates () {
  return request({
    url: '/shop/goods/category/all'
  })
}
// 请求首页banner
export function fetchHomeBanner () {
  return request({
    url: '/banner/list'
  })
}
// 请求商品列表，post请求不需要{}
const fetchItems = (params = {}) => {
  return request.post('/shop/goods/list', params)
}
// 请求商品的详情，形参id
// const fetchItemDetail = (id) => request.get('/shop/goods/detail', { params: { id } })
export function fetchItemDetail (id) {
  return request({
    url: '/shop/goods/detail',
    params: {
      id
    }
  })
}
// 导出，引入时需要加{}
export {
  fetchItems
}
